package org.fei.demo.service;

import org.fei.demo.entity.Blog;
import org.fei.demo.mapper.BlogMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class BlogService extends BasicService {
    private Logger logger = LoggerFactory.getLogger(BlogService.class);

    public BlogService(){}

    private BlogMapper mapper() throws IOException {
        return session().getMapper(BlogMapper.class);
    }

    public Blog findBlog(Long id){
        logger.info("开始查询Blog，id={}",id);
        try {
            return mapper().selectBlog(id);
        } catch (IOException e) {
            logger.info("select blog by id [{}]",id);
            logger.error("StackTrace: {}",e);
        }
        return null;
    }
}
